const app = getApp()
function wxpay(order_no) {
  app.request("/user/pay/aliPayApp_num", {
    method: "POST",
    data: {
      order_no
    }
  }).then(res => {
    console.log(res, "发起支付");
    let {
      timeStamp,
      nonceStr,
      signType,
      paySign
    } = res.data.data
    let packages = res.data.data.package
    let out_trade_no= res.data.order_id
    wx.requestPayment({
      timeStamp: timeStamp + '',
      nonceStr: nonceStr,
      package: packages,
      signType: signType,
      paySign: paySign,
      success(res) {
        console.log(res,"支付成功");
        //查询订单
        app.request("/user/pay/invest_search", {
          method: "POST",
          data:{
            out_trade_no
          }
        }).then(res=>{
          console.log(res,"订单查询");
        })
      }
    })
  })
}

export default wxpay;